//
//  RootViewController.m
//  LoLBox
//
//  Created by lanou3g on 15/5/28.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "RootViewController.h"
#import "ZhouBianViewController.h"
#import "GuanFangViewController.h"

@interface RootViewController ()

@property (nonatomic , strong)NSArray * loginArray;

@property (nonatomic , strong)NSArray * firstArray;

@property (nonatomic , strong)NSArray * secondArray;

@property (nonatomic , strong)NSArray * firstImageArray;

@property (nonatomic , strong)NSArray * secondImageArray;
@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self viewSetings];
    [self tableViewCellSetings];
    
}


-(void)tableViewCellSetings
{

    self.login.delegate = self;
    self.login.dataSource = self;
    self.login.tag = 101;
    self.login.bounces = NO;
    //分割线颜色
    [self.login setSeparatorColor:[UIColor magentaColor]];
    self.loginArray = [NSArray arrayWithObjects:@"用户登录", nil];
    
    self.firstTVC.delegate = self;
    self.firstTVC.dataSource = self;
    self.firstTVC.tag = 102;
    self.firstTVC.bounces = NO;
    [self.firstTVC setSeparatorColor:[UIColor magentaColor]];
    self.firstArray = [NSArray arrayWithObjects:@"官方论坛",@"周边服务", nil];
    self.firstImageArray = [NSArray arrayWithObjects:@"11",@"22" ,nil];
    
    self.secondTVC.delegate = self;
    self.secondTVC.dataSource = self;
    self.secondTVC.tag = 103;
    self.secondTVC.bounces = NO;
    [self.secondTVC setSeparatorColor:[UIColor magentaColor]];
    self.secondArray = [NSArray arrayWithObjects:@"二维码",@"英雄资料",@"英雄时刻" ,nil];
    self.secondImageArray = [NSArray arrayWithObjects:@"33",@"44",@"55", nil];
    
}


-(void)viewSetings
{
    self.navigationItem.title = @"发现";
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
    UIImageView * imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yekong.png"]];
    
    imageView.frame = CGRectMake(0, 0, 375, 675);
    
    [self.view addSubview:imageView];
    
    [self.view sendSubviewToBack:imageView];
}


//行的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        
        return 100;
    }
    
    return 55;
    
}

//区数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
    
    
}


//区的行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (tableView.tag == 101) {
        
        return _loginArray.count;
    }
    if (tableView.tag == 102) {
        
        return _firstArray.count;
    }
    if (tableView.tag == 103) {
        
        return _secondArray.count;
    }

    
    return 0;

}


//设置cell显示内容
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
#pragma mark-------------- -1
    if (tableView.tag == 101) {
        
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"logincell"];
    
    if (!cell) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"logincell"];
    }
    //cell设置透明  必须的3项
    cell.opaque = NO;

    cell.textLabel.backgroundColor = [UIColor clearColor];
    
    cell.backgroundColor = [UIColor colorWithRed:(250.0/255.0) green:(255.0/255.0) blue:(255.0/255.0) alpha:0.1];
        
       //点击样式
       cell.selectedBackgroundView =  [[UIImageView alloc]init];
        
       cell.selectedBackgroundView.backgroundColor = [UIColor purpleColor];
        
        //cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UILabel * label  = [[UILabel alloc]initWithFrame:CGRectMake(165, 30, 100, 40)];
        
        label.text = _loginArray[indexPath.row];
        
        [cell.contentView addSubview:label];
        
        label.textColor = [UIColor orangeColor];
        
        cell.contentView.frame = CGRectMake(125, 30, 40, 40);
        
        UIImage * image = [UIImage imageNamed:@"icon"];
        
        UIImageView * imageView = [[UIImageView alloc]initWithImage:image];
        
        imageView.frame = CGRectMake(110, 30, 40, 40);
        
        [cell.contentView addSubview:imageView];
        
       // label.font = [UIFont systemFontOfSize:20];
        
       // label.textAlignment = NSTextAlignmentCenter;
        
        
        
        return cell;
    }
    
#pragma mark---------------- -2
    if (tableView.tag == 102) {
        
        
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"firstcell"];
        
        if (!cell) {
            
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"firstcell"];
        }
        //cell设置透明  必须的3项
        cell.opaque = NO;
        
        cell.textLabel.backgroundColor = [UIColor clearColor];
        
        cell.backgroundColor = [UIColor colorWithRed:(250.0/255.0) green:(251.0/255.0) blue:(255.0/255.0) alpha:0.1];
        
        //点击样式
        cell.selectedBackgroundView =  [[UIImageView alloc]init];
        
        cell.selectedBackgroundView.backgroundColor = [UIColor purpleColor];
        
        
        UILabel * label  = [[UILabel alloc]initWithFrame:CGRectMake(60, 8, 100, 40)];
        
        label.text = _firstArray[indexPath.row];
        
        [cell.contentView addSubview:label];
        
        label.textColor = [UIColor orangeColor];

//        cell.textLabel.text = _firstArray[indexPath.row];
//        
//        cell.textLabel.textColor = [UIColor yellowColor];
        
        //cell.imageView.image = [UIImage imageNamed:_firstImageArray[indexPath.row]];
        
        cell.contentView.frame = CGRectMake(10, 8, 40, 40);
        
        UIImage * image = [UIImage imageNamed:_firstImageArray[indexPath.row]];
        
        UIImageView * imageView = [[UIImageView alloc]initWithImage:image];
        
        imageView.frame = CGRectMake(10, 8, 40, 40);
        
        [cell.contentView addSubview:imageView];
        
        return cell;
    }

#pragma mark----------------- -3
    if (tableView.tag == 103) {
        
        
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"secondcell"];
        
        if (!cell) {
            
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"secondcell"];
        }
        //cell设置透明  必须的3项
        cell.opaque = NO;
        
        cell.textLabel.backgroundColor = [UIColor clearColor];
        
        cell.backgroundColor = [UIColor colorWithRed:(250.0/255.0) green:(255.0/255.0) blue:(255.0/255.0) alpha:0.1];
        
        //点击样式
        cell.selectedBackgroundView =  [[UIImageView alloc]init];
    
        cell.selectedBackgroundView.backgroundColor = [UIColor purpleColor];
        
        UILabel * label  = [[UILabel alloc]initWithFrame:CGRectMake(60, 8, 100, 40)];
        
        label.text = _secondArray[indexPath.row];
        
        [cell.contentView addSubview:label];
        
        label.textColor = [UIColor orangeColor];
        
        //cell.textLabel.text = _secondArray[indexPath.row];
        
       // cell.textLabel.textColor = [UIColor yellowColor];
        
        cell.contentView.frame = CGRectMake(10, 8, 40, 40);
        
        UIImage * image = [UIImage imageNamed:_secondImageArray[indexPath.row]];
        
        UIImageView * imageView = [[UIImageView alloc]initWithImage:image];
        
        imageView.frame = CGRectMake(10, 8, 40, 40);
        
        [cell.contentView addSubview:imageView];
        
        return cell;
    }
        
    
    
    return nil;
}



//点击cell
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
    
    if (tableView.tag == 101) {
        
        [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];

        LoginViewController * loginVc = [[LoginViewController alloc]init];
        
        UINavigationController * Nc = [[UINavigationController alloc]initWithRootViewController:loginVc];
        
        [self.navigationController presentViewController:Nc animated:YES completion:^{
            nil;
        }];
        
    }
    
    if (tableView.tag == 102) {
        
    //点击后取消cell的选中颜色
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];

        if (indexPath.row == 0) {
            
            GuanFangViewController * guanfang = [[GuanFangViewController alloc]init];
            
            [self.navigationController pushViewController:guanfang animated:YES];
            

//            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://bbs.lol.qq.com/forum.php"]];
            
        }
        if (indexPath.row == 1) {
            
            ZhouBianViewController * zhoubian = [[ZhouBianViewController alloc]init];
            
            [self.navigationController pushViewController:zhoubian animated:YES
             ];
//            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://map.baidu.com"]];
        }
        
    }
    
    if (tableView.tag == 103) {
        
        
        if (indexPath.row == 0) {
            
            ErWeiMaViewController * erweimaVc= [[ErWeiMaViewController alloc]init];
            
            [self.navigationController pushViewController:erweimaVc animated:YES];
        }
        
        if (indexPath.row == 1) {
            
            
            DatumViewController * datumVc = [[DatumViewController alloc]init];
            
            [self.navigationController pushViewController:datumVc animated:YES];
            
        }
        
        
        if (indexPath.row == 2) {
        
        CollegeTableViewController * vc = [[CollegeTableViewController alloc]init];
        
        UINavigationController * NC = [[UINavigationController alloc]initWithRootViewController:vc];
        
        [self.navigationController presentViewController:NC animated:YES completion:^{
            nil;
        }        ];
        
          

      }

    }
    
    
     self.parentViewController.tabBarController.tabBar.hidden = YES;
    
}

-(void)viewWillAppear:(BOOL)animated
{
     self.parentViewController.tabBarController.tabBar.hidden = NO;
}




- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
